Hệ thống xếp lịch học tín chỉ cho sinh viên CNTT trên PHP & MySQL
111.140 lượt xem;
- class_time_table_dml.php
- project /
1 <?php
2
3 // Data functions (insert, update, delete, form) for table class_time_table
4
5 // This script and data application were generated by AppGini 5.72
6 // Download AppGini for free from https://bigprof.com/appgini/download/
7
8 function class_time_table_insert(){
9 global $Translation;
10
11 // mm: can member insert record?
12 $arrPerm=getTablePermissions('class_time_table');
13 if(!$arrPerm[1]){
14 return false;
15 }
16
17 $data['day'] = makeSafe($_REQUEST['day']);
18 if($data['day'] == empty_lookup_value){ $data['day'] = ''; }
19 $data['time_start'] = makeSafe($_REQUEST['time_start']);
20 if($data['time_start'] == empty_lookup_value){ $data['time_start'] = ''; }
21 $data['time_start'] = time24($data['time_start']);
22 $data['time_end'] = makeSafe($_REQUEST['time_end']);
23 if($data['time_end'] == empty_lookup_value){ $data['time_end'] = ''; }
24 $data['time_end'] = time24($data['time_end']);
25 $data['unit_code'] = makeSafe($_REQUEST['unit_code']);
26 if($data['unit_code'] == empty_lookup_value){ $data['unit_code'] = ''; }
27 $data['venue'] = makeSafe($_REQUEST['venue']);
28 if($data['venue'] == empty_lookup_value){ $data['venue'] = ''; }
29 $data['school'] = makeSafe($_REQUEST['school']);
30 if($data['school'] == empty_lookup_value){ $data['school'] = ''; }
31 $data['department'] = makeSafe($_REQUEST['department']);
32 if($data['department'] == empty_lookup_value){ $data['department'] = ''; }
33 $data['year_of_study'] = makeSafe($_REQUEST['year_of_study']);
34 if($data['year_of_study'] == empty_lookup_value){ $data['year_of_study'] = ''; }
35 if($data['day']== ''){
36 echo StyleSheet() . "\n\n<div class=\"alert alert-danger\">" . $Translation['error:'] . " 'Day': " . $Translation['field not null'] . '<br><br>';
37 echo '<a href="" onclick="history.go(-1); return false;">'.$Translation['< back'].'</a></div>';
38 exit;
39 }
40 if($data['time_start']== ''){
41 echo StyleSheet() . "\n\n<div class=\"alert alert-danger\">" . $Translation['error:'] . " ' Time Start': " . $Translation['field not null'] . '<br><br>';
42 echo '<a href="" onclick="history.go(-1); return false;">'.$Translation['< back'].'</a></div>';
43 exit;
44 }
45 if($data['time_end']== ''){
46 echo StyleSheet() . "\n\n<div class=\"alert alert-danger\">" . $Translation['error:'] . " 'Time End': " . $Translation['field not null'] . '<br><br>';
47 echo '<a href="" onclick="history.go(-1); return false;">'.$Translation['< back'].'</a></div>';
48 exit;
49 }
50 if($data['unit_code']== ''){
51 echo StyleSheet() . "\n\n<div class=\"alert alert-danger\">" . $Translation['error:'] . " 'Unit code': " . $Translation['field not null'] . '<br><br>';
52 echo '<a href="" onclick="history.go(-1); return false;">'.$Translation['< back'].'</a></div>';
53 exit;
54 }
55 if($data['venue']== ''){
56 echo StyleSheet() . "\n\n<div class=\"alert alert-danger\">" . $Translation['error:'] . " 'Venue': " . $Translation['field not null'] . '<br><br>';
57 echo '<a href="" onclick="history.go(-1); return false;">'.$Translation['< back'].'</a></div>';
58 exit;
59 }
60 if($data['school']== ''){
61 echo StyleSheet() . "\n\n<div class=\"alert alert-danger\">" . $Translation['error:'] . " 'School': " . $Translation['field not null'] . '<br><br>';
62 echo '<a href="" onclick="history.go(-1); return false;">'.$Translation['< back'].'</a></div>';
63 exit;
64 }
65 if($data['department']== ''){
66 echo StyleSheet() . "\n\n<div class=\"alert alert-danger\">" . $Translation['error:'] . " 'Department': " . $Translation['field not null'] . '<br><br>';
67 echo '<a href="" onclick="history.go(-1); return false;">'.$Translation['< back'].'</a></div>';
68 exit;
69 }
70 if($data['year_of_study']== ''){
71 echo StyleSheet() . "\n\n<div class=\"alert alert-danger\">" . $Translation['error:'] . " 'Year of study': " . $Translation['field not null'] . '<br><br>';
72 echo '<a href="" onclick="history.go(-1); return false;">'.$Translation['< back'].'</a></div>';
73 exit;
74 }
75
76 // hook: class_time_table_before_insert
77 if(function_exists('class_time_table_before_insert')){
78 $args=array();
79 if(!class_time_table_before_insert($data, getMemberInfo(), $args)){ return false; }
80 }
81
82 $o = array('silentErrors' => true);
83 sql('insert into `class_time_table` set `day`=' . (($data['day'] !== '' && $data['day'] !== NULL) ? "'{$data['day']}'" : 'NULL') . ', `time_start`=' . (($data['time_start'] !== '' && $data['time_start'] !== NULL) ? "'{$data['time_start']}'" : 'NULL') . ', `time_end`=' . (($data['time_end'] !== '' && $data['time_end'] !== NULL) ? "'{$data['time_end']}'" : 'NULL') . ', `unit_code`=' . (($data['unit_code'] !== '' && $data['unit_code'] !== NULL) ? "'{$data['unit_code']}'" : 'NULL') . ', `venue`=' . (($data['venue'] !== '' && $data['venue'] !== NULL) ? "'{$data['venue']}'" : 'NULL') . ', `school`=' . (($data['school'] !== '' && $data['school'] !== NULL) ? "'{$data['school']}'" : 'NULL') . ', `department`=' . (($data['department'] !== '' && $data['department'] !== NULL) ? "'{$data['department']}'" : 'NULL') . ', `year_of_study`=' . (($data['year_of_study'] !== '' && $data['year_of_study'] !== NULL) ? "'{$data['year_of_study']}'" : 'NULL'), $o);
84 if($o['error']!=''){
85 echo $o['error'];
86 echo "<a href=\"class_time_table_view.php?addNew_x=1\">{$Translation['< back']}</a>";
87 exit;
88 }
89
90 $recID = db_insert_id(db_link());
91
92 // hook: class_time_table_after_insert
93 if(function_exists('class_time_table_after_insert')){
94 $res = sql("select * from `class_time_table` where `id`='" . makeSafe($recID, false) . "' limit 1", $eo);
95 if($row = db_fetch_assoc($res)){
96 $data = array_map('makeSafe', $row);
97 }
98 $data['selectedID'] = makeSafe($recID, false);
99 $args=array();
100 if(!class_time_table_after_insert($data, getMemberInfo(), $args)){ return $recID; }
101 }
102
103 // mm: save ownership data
104 set_record_owner('class_time_table', $recID, getLoggedMemberID());
105
106 return $recID;
107 }
108
109 function class_time_table_delete($selected_id, $AllowDeleteOfParents=false, $skipChecks=false){
110 // insure referential integrity ...
111 global $Translation;
112 $selected_id=makeSafe($selected_id);
113
114 // mm: can member delete record?
115 $arrPerm=getTablePermissions('class_time_table');
116 $ownerGroupID=sqlValue("select groupID from membership_userrecords where tableName='class_time_table' and pkValue='$selected_id'");
117 $ownerMemberID=sqlValue("select lcase(memberID) from membership_userrecords where tableName='class_time_table' and pkValue='$selected_id'");
118 if(($arrPerm[4]==1 && $ownerMemberID==getLoggedMemberID()) || ($arrPerm[4]==2 && $ownerGroupID==getLoggedGroupID()) || $arrPerm[4]==3){ // allow delete?
119 // delete allowed, so continue ...
120 }else{
121 return $Translation['You don\'t have enough permissions to delete this record'];
122 }
123
124 // hook: class_time_table_before_delete
125 if(function_exists('class_time_table_before_delete')){
126 $args=array();
127 if(!class_time_table_before_delete($selected_id, $skipChecks, getMemberInfo(), $args))
128 return $Translation['Couldn\'t delete this record'];
129 }
130
131 sql("delete from `class_time_table` where `id`='$selected_id'", $eo);
132
133 // hook: class_time_table_after_delete
134 if(function_exists('class_time_table_after_delete')){
135 $args=array();
136 class_time_table_after_delete($selected_id, getMemberInfo(), $args);
137 }
138
139 // mm: delete ownership data
140 sql("delete from membership_userrecords where tableName='class_time_table' and pkValue='$selected_id'", $eo);
141 }
142
143 function class_time_table_update($selected_id){
144 global $Translation;
145
146 // mm: can member edit record?
147 $arrPerm=getTablePermissions('class_time_table');
148 $ownerGroupID=sqlValue("select groupID from membership_userrecords where tableName='class_time_table' and pkValue='".makeSafe($selected_id)."'");
149 $ownerMemberID=sqlValue("select lcase(memberID) from membership_userrecords where tableName='class_time_table' and pkValue='".makeSafe($selected_id)."'");
150 if(($arrPerm[3]==1 && $ownerMemberID==getLoggedMemberID()) || ($arrPerm[3]==2 && $ownerGroupID==getLoggedGroupID()) || $arrPerm[3]==3){ // allow update?
151 // update allowed, so continue ...
152 }else{
153 return false;
154 }
155
156 $data['day'] = makeSafe($_REQUEST['day']);
157 if($data['day'] == empty_lookup_value){ $data['day'] = ''; }
158 if($data['day']==''){
159 echo StyleSheet() . "\n\n<div class=\"alert alert-danger\">{$Translation['error:']} 'Day': {$Translation['field not null']}<br><br>";
160 echo '<a href="" onclick="history.go(-1); return false;">'.$Translation['< back'].'</a></div>';
161 exit;
162 }
163 $data['time_start'] = makeSafe($_REQUEST['time_start']);
164 if($data['time_start'] == empty_lookup_value){ $data['time_start'] = ''; }
165 $data['time_start'] = time24($data['time_start']);
166 if($data['time_start']==''){
167 echo StyleSheet() . "\n\n<div class=\"alert alert-danger\">{$Translation['error:']} ' Time Start': {$Translation['field not null']}<br><br>";
168 echo '<a href="" onclick="history.go(-1); return false;">'.$Translation['< back'].'</a></div>';
169 exit;
170 }
171 $data['time_end'] = makeSafe($_REQUEST['time_end']);
172 if($data['time_end'] == empty_lookup_value){ $data['time_end'] = ''; }
173 $data['time_end'] = time24($data['time_end']);
174 if($data['time_end']==''){
175 echo StyleSheet() . "\n\n<div class=\"alert alert-danger\">{$Translation['error:']} 'Time End': {$Translation['field not null']}<br><br>";
176 echo '<a href="" onclick="history.go(-1); return false;">'.$Translation['< back'].'</a></div>';
177 exit;
178 }
179 $data['unit_code'] = makeSafe($_REQUEST['unit_code']);
180 if($data['unit_code'] == empty_lookup_value){ $data['unit_code'] = ''; }
181 if($data['unit_code']==''){
182 echo StyleSheet() . "\n\n<div class=\"alert alert-danger\">{$Translation['error:']} 'Unit code': {$Translation['field not null']}<br><br>";
183 echo '<a href="" onclick="history.go(-1); return false;">'.$Translation['< back'].'</a></div>';
184 exit;
185 }
186 $data['venue'] = makeSafe($_REQUEST['venue']);
187 if($data['venue'] == empty_lookup_value){ $data['venue'] = ''; }
188 if($data['venue']==''){
189 echo StyleSheet() . "\n\n<div class=\"alert alert-danger\">{$Translation['error:']} 'Venue': {$Translation['field not null']}<br><br>";
190 echo '<a href="" onclick="history.go(-1); return false;">'.$Translation['< back'].'</a></div>';
191 exit;
192 }
193 $data['school'] = makeSafe($_REQUEST['school']);
194 if($data['school'] == empty_lookup_value){ $data['school'] = ''; }
195 if($data['school']==''){
196 echo StyleSheet() . "\n\n<div class=\"alert alert-danger\">{$Translation['error:']} 'School': {$Translation['field not null']}<br><br>";
197 echo '<a href="" onclick="history.go(-1); return false;">'.$Translation['< back'].'</a></div>';
198 exit;
199 }
200 $data['department'] = makeSafe($_REQUEST['department']);
201 if($data['department'] == empty_lookup_value){ $data['department'] = ''; }
202 if($data['department']==''){
203 echo StyleSheet() . "\n\n<div class=\"alert alert-danger\">{$Translation['error:']} 'Department': {$Translation['field not null']}<br><br>";
204 echo '<a href="" onclick="history.go(-1); return false;">'.$Translation['< back'].'</a></div>';
205 exit;
206 }
207 $data['year_of_study'] = makeSafe($_REQUEST['year_of_study']);
208 if($data['year_of_study'] == empty_lookup_value){ $data['year_of_study'] = ''; }
209 if($data['year_of_study']==''){
210 echo StyleSheet() . "\n\n<div class=\"alert alert-danger\">{$Translation['error:']} 'Year of study': {$Translation['field not null']}<br><br>";
211 echo '<a href="" onclick="history.go(-1); return false;">'.$Translation['< back'].'</a></div>';
212 exit;
213 }
214 $data['selectedID']=makeSafe($selected_id);
215
216 // hook: class_time_table_before_update
217 if(function_exists('class_time_table_before_update')){
218 $args=array();
219 if(!class_time_table_before_update($data, getMemberInfo(), $args)){ return false; }
220 }
221
222 $o=array('silentErrors' => true);
223 sql('update `class_time_table` set `day`=' . (($data['day'] !== '' && $data['day'] !== NULL) ? "'{$data['day']}'" : 'NULL') . ', `time_start`=' . (($data['time_start'] !== '' && $data['time_start'] !== NULL) ? "'{$data['time_start']}'" : 'NULL') . ', `time_end`=' . (($data['time_end'] !== '' && $data['time_end'] !== NULL) ? "'{$data['time_end']}'" : 'NULL') . ', `unit_code`=' . (($data['unit_code'] !== '' && $data['unit_code'] !== NULL) ? "'{$data['unit_code']}'" : 'NULL') . ', `venue`=' . (($data['venue'] !== '' && $data['venue'] !== NULL) ? "'{$data['venue']}'" : 'NULL') . ', `school`=' . (($data['school'] !== '' && $data['school'] !== NULL) ? "'{$data['school']}'" : 'NULL') . ', `department`=' . (($data['department'] !== '' && $data['department'] !== NULL) ? "'{$data['department']}'" : 'NULL') . ', `year_of_study`=' . (($data['year_of_study'] !== '' && $data['year_of_study'] !== NULL) ? "'{$data['year_of_study']}'" : 'NULL') . " where `id`='".makeSafe($selected_id)."'", $o);
224 if($o['error']!=''){
225 echo $o['error'];
226 echo '<a href="class_time_table_view.php?SelectedID='.urlencode($selected_id)."\">{$Translation['< back']}</a>";
227 exit;
228 }
229
230
231 // hook: class_time_table_after_update
232 if(function_exists('class_time_table_after_update')){
233 $res = sql("SELECT * FROM `class_time_table` WHERE `id`='{$data['selectedID']}' LIMIT 1", $eo);
234 if($row = db_fetch_assoc($res)){
235 $data = array_map('makeSafe', $row);
236 }
237 $data['selectedID'] = $data['id'];
238 $args = array();
239 if(!class_time_table_after_update($data, getMemberInfo(), $args)){ return; }
240 }
241
242 // mm: update ownership data
243 sql("update membership_userrecords set dateUpdated='".time()."' where tableName='class_time_table' and pkValue='".makeSafe($selected_id)."'", $eo);
244
245 }
246
247 function class_time_table_form($selected_id = '', $AllowUpdate = 1, $AllowInsert = 1, $AllowDelete = 1, $ShowCancel = 0, $TemplateDV = '', $TemplateDVP = ''){
248 // function to return an editable form for a table records
249 // and fill it with data of record whose ID is $selected_id. If $selected_id
250 // is empty, an empty form is shown, with only an 'Add New'
251 // button displayed.
252
253 global $Translation;
254
255 // mm: get table permissions
256 $arrPerm=getTablePermissions('class_time_table');
257 if(!$arrPerm[1] && $selected_id==''){ return ''; }
258 $AllowInsert = ($arrPerm[1] ? true : false);
259 // print preview?
260 $dvprint = false;
261 if($selected_id && $_REQUEST['dvprint_x'] != ''){
262 $dvprint = true;
263 }
264
265 $filterer_school = thisOr(undo_magic_quotes($_REQUEST['filterer_school']), '');
266 $filterer_department = thisOr(undo_magic_quotes($_REQUEST['filterer_department']), '');
267
268 // populate filterers, starting from children to grand-parents
269 if($filterer_department && !$filterer_school) $filterer_school = sqlValue("select school from departments where id='" . makeSafe($filterer_department) . "'");
270
271 // unique random identifier
272 $rnd1 = ($dvprint ? rand(1000000, 9999999) : '');
273 // combobox: day
274 $combo_day = new Combo;
275 $combo_day->ListType = 0;
276 $combo_day->MultipleSeparator = ', ';
277 $combo_day->ListBoxHeight = 10;
278 $combo_day->RadiosPerLine = 1;
279 if(is_file(dirname(__FILE__).'/hooks/class_time_table.day.csv')){
280 $day_data = addslashes(implode('', @file(dirname(__FILE__).'/hooks/class_time_table.day.csv')));
281 $combo_day->ListItem = explode('||', entitiesToUTF8(convertLegacyOptions($day_data)));
282 $combo_day->ListData = $combo_day->ListItem;
283 }else{
284 $combo_day->ListItem = explode('||', entitiesToUTF8(convertLegacyOptions("Monday;;Tuesday;;Wednesday;;Thursday;;Friday;;Saturday;;Sunday")));
285 $combo_day->ListData = $combo_day->ListItem;
286 }
287 $combo_day->SelectName = 'day';
288 $combo_day->AllowNull = false;
289 // combobox: school
290 $combo_school = new DataCombo;
291 // combobox: department, filterable by: school
292 $combo_department = new DataCombo;
293 // combobox: year_of_study
294 $combo_year_of_study = new Combo;
295 $combo_year_of_study->ListType = 0;
296 $combo_year_of_study->MultipleSeparator = ', ';
297 $combo_year_of_study->ListBoxHeight = 10;
298 $combo_year_of_study->RadiosPerLine = 1;
299 if(is_file(dirname(__FILE__).'/hooks/class_time_table.year_of_study.csv')){
300 $year_of_study_data = addslashes(implode('', @file(dirname(__FILE__).'/hooks/class_time_table.year_of_study.csv')));
301 $combo_year_of_study->ListItem = explode('||', entitiesToUTF8(convertLegacyOptions($year_of_study_data)));
302 $combo_year_of_study->ListData = $combo_year_of_study->ListItem;
303 }else{
304 $combo_year_of_study->ListItem = explode('||', entitiesToUTF8(convertLegacyOptions("1;;2;;3;;4;;5;;6")));
305 $combo_year_of_study->ListData = $combo_year_of_study->ListItem;
306 }
307 $combo_year_of_study->SelectName = 'year_of_study';
308 $combo_year_of_study->AllowNull = false;
309
310 if($selected_id){
311 // mm: check member permissions
312 if(!$arrPerm[2]){
313 return "";
314 }
315 // mm: who is the owner?
316 $ownerGroupID=sqlValue("select groupID from membership_userrecords where tableName='class_time_table' and pkValue='".makeSafe($selected_id)."'");
317 $ownerMemberID=sqlValue("select lcase(memberID) from membership_userrecords where tableName='class_time_table' and pkValue='".makeSafe($selected_id)."'");
318 if($arrPerm[2]==1 && getLoggedMemberID()!=$ownerMemberID){
319 return "";
320 }
321 if($arrPerm[2]==2 && getLoggedGroupID()!=$ownerGroupID){
322 return "";
323 }
324
325 // can edit?
326 if(($arrPerm[3]==1 && $ownerMemberID==getLoggedMemberID()) || ($arrPerm[3]==2 && $ownerGroupID==getLoggedGroupID()) || $arrPerm[3]==3){
327 $AllowUpdate=1;
328 }else{
329 $AllowUpdate=0;
330 }
331
332 $res = sql("select * from `class_time_table` where `id`='".makeSafe($selected_id)."'", $eo);
333 if(!($row = db_fetch_array($res))){
334 return error_message($Translation['No records found'], 'class_time_table_view.php', false);
335 }
336 $urow = $row; /* unsanitized data */
337 $hc = new CI_Input();
338 $row = $hc->xss_clean($row); /* sanitize data */
339 $combo_day->SelectedData = $row['day'];
340 $combo_school->SelectedData = $row['school'];
341 $combo_department->SelectedData = $row['department'];
342 $combo_year_of_study->SelectedData = $row['year_of_study'];
343 }else{
344 $combo_day->SelectedText = ( $_REQUEST['FilterField'][1]=='2' && $_REQUEST['FilterOperator'][1]=='<=>' ? (get_magic_quotes_gpc() ? stripslashes($_REQUEST['FilterValue'][1]) : $_REQUEST['FilterValue'][1]) : "");
345 $combo_school->SelectedData = $filterer_school;
346 $combo_department->SelectedData = $filterer_department;
347 $combo_year_of_study->SelectedText = ( $_REQUEST['FilterField'][1]=='9' && $_REQUEST['FilterOperator'][1]=='<=>' ? (get_magic_quotes_gpc() ? stripslashes($_REQUEST['FilterValue'][1]) : $_REQUEST['FilterValue'][1]) : "");
348 }
349 $combo_day->Render();
350 $combo_school->HTML = '<span id="school-container' . $rnd1 . '"></span><input type="hidden" name="school" id="school' . $rnd1 . '" value="' . html_attr($combo_school->SelectedData) . '">';
351 $combo_school->MatchText = '<span id="school-container-readonly' . $rnd1 . '"></span><input type="hidden" name="school" id="school' . $rnd1 . '" value="' . html_attr($combo_school->SelectedData) . '">';
352 $combo_department->HTML = '<span id="department-container' . $rnd1 . '"></span><input type="hidden" name="department" id="department' . $rnd1 . '" value="' . html_attr($combo_department->SelectedData) . '">';
353 $combo_department->MatchText = '<span id="department-container-readonly' . $rnd1 . '"></span><input type="hidden" name="department" id="department' . $rnd1 . '" value="' . html_attr($combo_department->SelectedData) . '">';
354 $combo_year_of_study->Render();
355
356 ob_start();
357 ?>
358
359 <script>
360 // initial lookup values
361 AppGini.current_school__RAND__ = { text: "", value: "<?php echo addslashes($selected_id ? $urow['school'] : $filterer_school); ?>"};
362 AppGini.current_department__RAND__ = { text: "", value: "<?php echo addslashes($selected_id ? $urow['department'] : $filterer_department); ?>"};
363
364 jQuery(function() {
365 setTimeout(function(){
366 if(typeof(school_reload__RAND__) == 'function') school_reload__RAND__();
367 <?php echo (!$AllowUpdate || $dvprint ? 'if(typeof(department_reload__RAND__) == \'function\') department_reload__RAND__(AppGini.current_school__RAND__.value);' : ''); ?>
368 }, 10); /* we need to slightly delay client-side execution of the above code to allow AppGini.ajaxCache to work */
369 });
370 function school_reload__RAND__(){
371 <?php if(($AllowUpdate || $AllowInsert) && !$dvprint){ ?>
372
373 $j("#school-container__RAND__").select2({
374 /* initial default value */
375 initSelection: function(e, c){
376 $j.ajax({
377 url: 'ajax_combo.php',
378 dataType: 'json',
379 data: { id: AppGini.current_school__RAND__.value, t: 'class_time_table', f: 'school' },
380 success: function(resp){
381 c({
382 id: resp.results[0].id,
383 text: resp.results[0].text
384 });
385 $j('[name="school"]').val(resp.results[0].id);
386 $j('[id=school-container-readonly__RAND__]').html('<span id="school-match-text">' + resp.results[0].text + '</span>');
387 if(resp.results[0].id == '<?php echo empty_lookup_value; ?>'){ $j('.btn[id=schools_view_parent]').hide(); }else{ $j('.btn[id=schools_view_parent]').show(); }
388
389 if(typeof(department_reload__RAND__) == 'function') department_reload__RAND__(AppGini.current_school__RAND__.value);
390
391 if(typeof(school_update_autofills__RAND__) == 'function') school_update_autofills__RAND__();
392 }
393 });
394 },
395 width: '100%',
396 formatNoMatches: function(term){ /* */ return '<?php echo addslashes($Translation['No matches found!']); ?>'; },
397 minimumResultsForSearch: 10,
398 loadMorePadding: 200,
399 ajax: {
400 url: 'ajax_combo.php',
401 dataType: 'json',
402 cache: true,
403 data: function(term, page){ /* */ return { s: term, p: page, t: 'class_time_table', f: 'school' }; },
404 results: function(resp, page){ /* */ return resp; }
405 },
406 escapeMarkup: function(str){ /* */ return str; }
407 }).on('change', function(e){
408 AppGini.current_school__RAND__.value = e.added.id;
409 AppGini.current_school__RAND__.text = e.added.text;
410 $j('[name="school"]').val(e.added.id);
411 if(e.added.id == '<?php echo empty_lookup_value; ?>'){ $j('.btn[id=schools_view_parent]').hide(); }else{ $j('.btn[id=schools_view_parent]').show(); }
412
413 if(typeof(department_reload__RAND__) == 'function') department_reload__RAND__(AppGini.current_school__RAND__.value);
414
415 if(typeof(school_update_autofills__RAND__) == 'function') school_update_autofills__RAND__();
416 });
417
418 if(!$j("#school-container__RAND__").length){
419 $j.ajax({
420 url: 'ajax_combo.php',
421 dataType: 'json',
422 data: { id: AppGini.current_school__RAND__.value, t: 'class_time_table', f: 'school' },
423 success: function(resp){
424 $j('[name="school"]').val(resp.results[0].id);
425 $j('[id=school-container-readonly__RAND__]').html('<span id="school-match-text">' + resp.results[0].text + '</span>');
426 if(resp.results[0].id == '<?php echo empty_lookup_value; ?>'){ $j('.btn[id=schools_view_parent]').hide(); }else{ $j('.btn[id=schools_view_parent]').show(); }
427
428 if(typeof(school_update_autofills__RAND__) == 'function') school_update_autofills__RAND__();
429 }
430 });
431 }
432
433 <?php }else{ ?>
434
435 $j.ajax({
436 url: 'ajax_combo.php',
437 dataType: 'json',
438 data: { id: AppGini.current_school__RAND__.value, t: 'class_time_table', f: 'school' },
439 success: function(resp){
440 $j('[id=school-container__RAND__], [id=school-container-readonly__RAND__]').html('<span id="school-match-text">' + resp.results[0].text + '</span>');
441 if(resp.results[0].id == '<?php echo empty_lookup_value; ?>'){ $j('.btn[id=schools_view_parent]').hide(); }else{ $j('.btn[id=schools_view_parent]').show(); }
442
443 if(typeof(school_update_autofills__RAND__) == 'function') school_update_autofills__RAND__();
444 }
445 });
446 <?php } ?>
447
448 }
449 function department_reload__RAND__(filterer_school){
450 <?php if(($AllowUpdate || $AllowInsert) && !$dvprint){ ?>
451
452 $j("#department-container__RAND__").select2({
453 /* initial default value */
454 initSelection: function(e, c){
455 $j.ajax({
456 url: 'ajax_combo.php',
457 dataType: 'json',
458 data: { filterer_school: filterer_school, id: AppGini.current_department__RAND__.value, t: 'class_time_table', f: 'department' },
459 success: function(resp){
460 c({
461 id: resp.results[0].id,
462 text: resp.results[0].text
463 });
464 $j('[name="department"]').val(resp.results[0].id);
465 $j('[id=department-container-readonly__RAND__]').html('<span id="department-match-text">' + resp.results[0].text + '</span>');
466 if(resp.results[0].id == '<?php echo empty_lookup_value; ?>'){ $j('.btn[id=departments_view_parent]').hide(); }else{ $j('.btn[id=departments_view_parent]').show(); }
467
468
469 if(typeof(department_update_autofills__RAND__) == 'function') department_update_autofills__RAND__();
470 }
471 });
472 },
473 width: '100%',
474 formatNoMatches: function(term){ /* */ return '<?php echo addslashes($Translation['No matches found!']); ?>'; },
475 minimumResultsForSearch: 10,
476 loadMorePadding: 200,
477 ajax: {
478 url: 'ajax_combo.php',
479 dataType: 'json',
480 cache: true,
481 data: function(term, page){ /* */ return { filterer_school: filterer_school, s: term, p: page, t: 'class_time_table', f: 'department' }; },
482 results: function(resp, page){ /* */ return resp; }
483 },
484 escapeMarkup: function(str){ /* */ return str; }
485 }).on('change', function(e){
486 AppGini.current_department__RAND__.value = e.added.id;
487 AppGini.current_department__RAND__.text = e.added.text;
488 $j('[name="department"]').val(e.added.id);
489 if(e.added.id == '<?php echo empty_lookup_value; ?>'){ $j('.btn[id=departments_view_parent]').hide(); }else{ $j('.btn[id=departments_view_parent]').show(); }
490
491
492 if(typeof(department_update_autofills__RAND__) == 'function') department_update_autofills__RAND__();
493 });
494
495 if(!$j("#department-container__RAND__").length){
496 $j.ajax({
497 url: 'ajax_combo.php',
498 dataType: 'json',
499 data: { id: AppGini.current_department__RAND__.value, t: 'class_time_table', f: 'department' },
500 success: function(resp){
501 $j('[name="department"]').val(resp.results[0].id);
502 $j('[id=department-container-readonly__RAND__]').html('<span id="department-match-text">' + resp.results[0].text + '</span>');
503 if(resp.results[0].id == '<?php echo empty_lookup_value; ?>'){ $j('.btn[id=departments_view_parent]').hide(); }else{ $j('.btn[id=departments_view_parent]').show(); }
504
505 if(typeof(department_update_autofills__RAND__) == 'function') department_update_autofills__RAND__();
506 }
507 });
508 }
509
510 <?php }else{ ?>
511
512 $j.ajax({
513 url: 'ajax_combo.php',
514 dataType: 'json',
515 data: { id: AppGini.current_department__RAND__.value, t: 'class_time_table', f: 'department' },
516 success: function(resp){
517 $j('[id=department-container__RAND__], [id=department-container-readonly__RAND__]').html('<span id="department-match-text">' + resp.results[0].text + '</span>');
518 if(resp.results[0].id == '<?php echo empty_lookup_value; ?>'){ $j('.btn[id=departments_view_parent]').hide(); }else{ $j('.btn[id=departments_view_parent]').show(); }
519
520 if(typeof(department_update_autofills__RAND__) == 'function') department_update_autofills__RAND__();
521 }
522 });
523 <?php } ?>
524
525 }
526 </script>
527 <?php
528
529 $lookups = str_replace('__RAND__', $rnd1, ob_get_contents());
530 ob_end_clean();
531
532
533 // code for template based detail view forms
534
535 // open the detail view template
536 if($dvprint){
537 $template_file = is_file("./{$TemplateDVP}") ? "./{$TemplateDVP}" : './templates/class_time_table_templateDVP.html';
538 $templateCode = @file_get_contents($template_file);
539 }else{
540 $template_file = is_file("./{$TemplateDV}") ? "./{$TemplateDV}" : './templates/class_time_table_templateDV.html';
541 $templateCode = @file_get_contents($template_file);
542 }
543
544 // process form title
545 $templateCode = str_replace('<%%DETAIL_VIEW_TITLE%%>', 'Thông tin lịch học', $templateCode);
546 $templateCode = str_replace('<%%RND1%%>', $rnd1, $templateCode);
547 $templateCode = str_replace('<%%EMBEDDED%%>', ($_REQUEST['Embedded'] ? 'Embedded=1' : ''), $templateCode);
548 // process buttons
549 if($AllowInsert){
550 if(!$selected_id) $templateCode = str_replace('<%%INSERT_BUTTON%%>', '<button type="submit" class="btn btn-success" id="insert" name="insert_x" value="1" onclick="return class_time_table_validateData();"><i class="glyphicon glyphicon-plus-sign"></i> ' . $Translation['Save New'] . '</button>', $templateCode);
551 $templateCode = str_replace('<%%INSERT_BUTTON%%>', '<button type="submit" class="btn btn-default" id="insert" name="insert_x" value="1" onclick="return class_time_table_validateData();"><i class="glyphicon glyphicon-plus-sign"></i> ' . $Translation['Save As Copy'] . '</button>', $templateCode);
552 }else{
553 $templateCode = str_replace('<%%INSERT_BUTTON%%>', '', $templateCode);
554 }
555
556 // 'Back' button action
557 if($_REQUEST['Embedded']){
558 $backAction = 'AppGini.closeParentModal(); return false;';
559 }else{
560 $backAction = '$j(\'form\').eq(0).attr(\'novalidate\', \'novalidate\'); document.myform.reset(); return true;';
561 }
562
563 if($selected_id){
564 if(!$_REQUEST['Embedded']) $templateCode = str_replace('<%%DVPRINT_BUTTON%%>', '<button type="submit" class="btn btn-default" id="dvprint" name="dvprint_x" value="1" onclick="$$(\'form\')[0].writeAttribute(\'novalidate\', \'novalidate\'); document.myform.reset(); return true;" title="' . html_attr($Translation['Print Preview']) . '"><i class="glyphicon glyphicon-print"></i> ' . $Translation['Print Preview'] . '</button>', $templateCode);
565 if($AllowUpdate){
566 $templateCode = str_replace('<%%UPDATE_BUTTON%%>', '<button type="submit" class="btn btn-success btn-lg" id="update" name="update_x" value="1" onclick="return class_time_table_validateData();" title="' . html_attr($Translation['Save Changes']) . '"><i class="glyphicon glyphicon-ok"></i> ' . $Translation['Save Changes'] . '</button>', $templateCode);
567 }else{
568 $templateCode = str_replace('<%%UPDATE_BUTTON%%>', '', $templateCode);
569 }
570 if(($arrPerm[4]==1 && $ownerMemberID==getLoggedMemberID()) || ($arrPerm[4]==2 && $ownerGroupID==getLoggedGroupID()) || $arrPerm[4]==3){ // allow delete?
571 $templateCode = str_replace('<%%DELETE_BUTTON%%>', '<button type="submit" class="btn btn-danger" id="delete" name="delete_x" value="1" onclick="return confirm(\'' . $Translation['are you sure?'] . '\');" title="' . html_attr($Translation['Delete']) . '"><i class="glyphicon glyphicon-trash"></i> ' . $Translation['Delete'] . '</button>', $templateCode);
572 }else{
573 $templateCode = str_replace('<%%DELETE_BUTTON%%>', '', $templateCode);
574 }
575 $templateCode = str_replace('<%%DESELECT_BUTTON%%>', '<button type="submit" class="btn btn-default" id="deselect" name="deselect_x" value="1" onclick="' . $backAction . '" title="' . html_attr($Translation['Back']) . '"><i class="glyphicon glyphicon-chevron-left"></i> ' . $Translation['Back'] . '</button>', $templateCode);
576 }else{
577 $templateCode = str_replace('<%%UPDATE_BUTTON%%>', '', $templateCode);
578 $templateCode = str_replace('<%%DELETE_BUTTON%%>', '', $templateCode);
579 $templateCode = str_replace('<%%DESELECT_BUTTON%%>', ($ShowCancel ? '<button type="submit" class="btn btn-default" id="deselect" name="deselect_x" value="1" onclick="' . $backAction . '" title="' . html_attr($Translation['Back']) . '"><i class="glyphicon glyphicon-chevron-left"></i> ' . $Translation['Back'] . '</button>' : ''), $templateCode);
580 }
581
582 // set records to read only if user can't insert new records and can't edit current record
583 if(($selected_id && !$AllowUpdate && !$AllowInsert) || (!$selected_id && !$AllowInsert)){
584 $jsReadOnly .= "\tjQuery('#day').replaceWith('<div class=\"form-control-static\" id=\"day\">' + (jQuery('#day').val() || '') + '</div>'); jQuery('#day-multi-selection-help').hide();\n";
585 $jsReadOnly .= "\tjQuery('#time_start').replaceWith('<div class=\"form-control-static\" id=\"time_start\">' + (jQuery('#time_start').val() || '') + '</div>');\n";
586 $jsReadOnly .= "\tjQuery('#time_end').replaceWith('<div class=\"form-control-static\" id=\"time_end\">' + (jQuery('#time_end').val() || '') + '</div>');\n";
587 $jsReadOnly .= "\tjQuery('#unit_code').replaceWith('<div class=\"form-control-static\" id=\"unit_code\">' + (jQuery('#unit_code').val() || '') + '</div>');\n";
588 $jsReadOnly .= "\tjQuery('#venue').replaceWith('<div class=\"form-control-static\" id=\"venue\">' + (jQuery('#venue').val() || '') + '</div>');\n";
589 $jsReadOnly .= "\tjQuery('#school').prop('disabled', true).css({ color: '#555', backgroundColor: '#fff' });\n";
590 $jsReadOnly .= "\tjQuery('#school_caption').prop('disabled', true).css({ color: '#555', backgroundColor: 'white' });\n";
591 $jsReadOnly .= "\tjQuery('#department').prop('disabled', true).css({ color: '#555', backgroundColor: '#fff' });\n";
592 $jsReadOnly .= "\tjQuery('#department_caption').prop('disabled', true).css({ color: '#555', backgroundColor: 'white' });\n";
593 $jsReadOnly .= "\tjQuery('#year_of_study').replaceWith('<div class=\"form-control-static\" id=\"year_of_study\">' + (jQuery('#year_of_study').val() || '') + '</div>'); jQuery('#year_of_study-multi-selection-help').hide();\n";
594 $jsReadOnly .= "\tjQuery('.select2-container').hide();\n";
595
596 $noUploads = true;
597 }elseif($AllowInsert){
598 $jsEditable .= "\tjQuery('form').eq(0).data('already_changed', true);"; // temporarily disable form change handler
599 $jsEditable .= "\tjQuery('#time_start').addClass('always_shown').timepicker({ defaultTime: false, showSeconds: true, showMeridian: true, showInputs: false, disableFocus: true, minuteStep: 5 });";
600 $jsEditable .= "\tjQuery('#time_end').addClass('always_shown').timepicker({ defaultTime: false, showSeconds: true, showMeridian: true, showInputs: false, disableFocus: true, minuteStep: 5 });";
601 $jsEditable .= "\tjQuery('form').eq(0).data('already_changed', false);"; // re-enable form change handler
602 }
603
604 // process combos
605 $templateCode = str_replace('<%%COMBO(day)%%>', $combo_day->HTML, $templateCode);
606 $templateCode = str_replace('<%%COMBOTEXT(day)%%>', $combo_day->SelectedData, $templateCode);
607 $templateCode = str_replace('<%%COMBO(school)%%>', $combo_school->HTML, $templateCode);
608 $templateCode = str_replace('<%%COMBOTEXT(school)%%>', $combo_school->MatchText, $templateCode);
609 $templateCode = str_replace('<%%URLCOMBOTEXT(school)%%>', urlencode($combo_school->MatchText), $templateCode);
610 $templateCode = str_replace('<%%COMBO(department)%%>', $combo_department->HTML, $templateCode);
611 $templateCode = str_replace('<%%COMBOTEXT(department)%%>', $combo_department->MatchText, $templateCode);
612 $templateCode = str_replace('<%%URLCOMBOTEXT(department)%%>', urlencode($combo_department->MatchText), $templateCode);
613 $templateCode = str_replace('<%%COMBO(year_of_study)%%>', $combo_year_of_study->HTML, $templateCode);
614 $templateCode = str_replace('<%%COMBOTEXT(year_of_study)%%>', $combo_year_of_study->SelectedData, $templateCode);
615
616 /* lookup fields array: 'lookup field name' => array('parent table name', 'lookup field caption') */
617 $lookup_fields = array( 'school' => array('schools', 'School'), 'department' => array('departments', 'Department'));
618 foreach($lookup_fields as $luf => $ptfc){
619 $pt_perm = getTablePermissions($ptfc[0]);
620
621 // process foreign key links
622 if($pt_perm['view'] || $pt_perm['edit']){
623 $templateCode = str_replace("<%%PLINK({$luf})%%>", '<button type="button" class="btn btn-default view_parent hspacer-md" id="' . $ptfc[0] . '_view_parent" title="' . html_attr($Translation['View'] . ' ' . $ptfc[1]) . '"><i class="glyphicon glyphicon-eye-open"></i></button>', $templateCode);
624 }
625
626 // if user has insert permission to parent table of a lookup field, put an add new button
627 if($pt_perm['insert'] && !$_REQUEST['Embedded']){
628 $templateCode = str_replace("<%%ADDNEW({$ptfc[0]})%%>", '<button type="button" class="btn btn-success add_new_parent hspacer-md" id="' . $ptfc[0] . '_add_new" title="' . html_attr($Translation['Add New'] . ' ' . $ptfc[1]) . '"><i class="glyphicon glyphicon-plus-sign"></i></button>', $templateCode);
629 }
630 }
631
632 // process images
633 $templateCode = str_replace('<%%UPLOADFILE(id)%%>', '', $templateCode);
634 $templateCode = str_replace('<%%UPLOADFILE(day)%%>', '', $templateCode);
635 $templateCode = str_replace('<%%UPLOADFILE(time_start)%%>', '', $templateCode);
636 $templateCode = str_replace('<%%UPLOADFILE(time_end)%%>', '', $templateCode);
637 $templateCode = str_replace('<%%UPLOADFILE(unit_code)%%>', '', $templateCode);
638 $templateCode = str_replace('<%%UPLOADFILE(venue)%%>', '', $templateCode);
639 $templateCode = str_replace('<%%UPLOADFILE(school)%%>', '', $templateCode);
640 $templateCode = str_replace('<%%UPLOADFILE(department)%%>', '', $templateCode);
641 $templateCode = str_replace('<%%UPLOADFILE(year_of_study)%%>', '', $templateCode);
642
643 // process values
644 if($selected_id){
645 if( $dvprint) $templateCode = str_replace('<%%VALUE(id)%%>', safe_html($urow['id']), $templateCode);
646 if(!$dvprint) $templateCode = str_replace('<%%VALUE(id)%%>', html_attr($row['id']), $templateCode);
647 $templateCode = str_replace('<%%URLVALUE(id)%%>', urlencode($urow['id']), $templateCode);
648 if( $dvprint) $templateCode = str_replace('<%%VALUE(day)%%>', safe_html($urow['day']), $templateCode);
649 if(!$dvprint) $templateCode = str_replace('<%%VALUE(day)%%>', html_attr($row['day']), $templateCode);
650 $templateCode = str_replace('<%%URLVALUE(day)%%>', urlencode($urow['day']), $templateCode);
651 $templateCode = str_replace('<%%VALUE(time_start)%%>', time12(html_attr($row['time_start'])), $templateCode);
652 $templateCode = str_replace('<%%URLVALUE(time_start)%%>', urlencode(time12($urow['time_start'])), $templateCode);
653 $templateCode = str_replace('<%%VALUE(time_end)%%>', time12(html_attr($row['time_end'])), $templateCode);
654 $templateCode = str_replace('<%%URLVALUE(time_end)%%>', urlencode(time12($urow['time_end'])), $templateCode);
655 if( $dvprint) $templateCode = str_replace('<%%VALUE(unit_code)%%>', safe_html($urow['unit_code']), $templateCode);
656 if(!$dvprint) $templateCode = str_replace('<%%VALUE(unit_code)%%>', html_attr($row['unit_code']), $templateCode);
657 $templateCode = str_replace('<%%URLVALUE(unit_code)%%>', urlencode($urow['unit_code']), $templateCode);
658 if( $dvprint) $templateCode = str_replace('<%%VALUE(venue)%%>', safe_html($urow['venue']), $templateCode);
659 if(!$dvprint) $templateCode = str_replace('<%%VALUE(venue)%%>', html_attr($row['venue']), $templateCode);
660 $templateCode = str_replace('<%%URLVALUE(venue)%%>', urlencode($urow['venue']), $templateCode);
661 if( $dvprint) $templateCode = str_replace('<%%VALUE(school)%%>', safe_html($urow['school']), $templateCode);
662 if(!$dvprint) $templateCode = str_replace('<%%VALUE(school)%%>', html_attr($row['school']), $templateCode);
663 $templateCode = str_replace('<%%URLVALUE(school)%%>', urlencode($urow['school']), $templateCode);
664 if( $dvprint) $templateCode = str_replace('<%%VALUE(department)%%>', safe_html($urow['department']), $templateCode);
665 if(!$dvprint) $templateCode = str_replace('<%%VALUE(department)%%>', html_attr($row['department']), $templateCode);
666 $templateCode = str_replace('<%%URLVALUE(department)%%>', urlencode($urow['department']), $templateCode);
667 if( $dvprint) $templateCode = str_replace('<%%VALUE(year_of_study)%%>', safe_html($urow['year_of_study']), $templateCode);
668 if(!$dvprint) $templateCode = str_replace('<%%VALUE(year_of_study)%%>', html_attr($row['year_of_study']), $templateCode);
669 $templateCode = str_replace('<%%URLVALUE(year_of_study)%%>', urlencode($urow['year_of_study']), $templateCode);
670 }else{
671 $templateCode = str_replace('<%%VALUE(id)%%>', '', $templateCode);
672 $templateCode = str_replace('<%%URLVALUE(id)%%>', urlencode(''), $templateCode);
673 $templateCode = str_replace('<%%VALUE(day)%%>', '', $templateCode);
674 $templateCode = str_replace('<%%URLVALUE(day)%%>', urlencode(''), $templateCode);
675 $templateCode = str_replace('<%%VALUE(time_start)%%>', time12(''), $templateCode);
676 $templateCode = str_replace('<%%URLVALUE(time_start)%%>', urlencode(time12('')), $templateCode);
677 $templateCode = str_replace('<%%VALUE(time_end)%%>', time12(''), $templateCode);
678 $templateCode = str_replace('<%%URLVALUE(time_end)%%>', urlencode(time12('')), $templateCode);
679 $templateCode = str_replace('<%%VALUE(unit_code)%%>', '', $templateCode);
680 $templateCode = str_replace('<%%URLVALUE(unit_code)%%>', urlencode(''), $templateCode);
681 $templateCode = str_replace('<%%VALUE(venue)%%>', '', $templateCode);
682 $templateCode = str_replace('<%%URLVALUE(venue)%%>', urlencode(''), $templateCode);
683 $templateCode = str_replace('<%%VALUE(school)%%>', '', $templateCode);
684 $templateCode = str_replace('<%%URLVALUE(school)%%>', urlencode(''), $templateCode);
685 $templateCode = str_replace('<%%VALUE(department)%%>', '', $templateCode);
686 $templateCode = str_replace('<%%URLVALUE(department)%%>', urlencode(''), $templateCode);
687 $templateCode = str_replace('<%%VALUE(year_of_study)%%>', '', $templateCode);
688 $templateCode = str_replace('<%%URLVALUE(year_of_study)%%>', urlencode(''), $templateCode);
689 }
690
691 // process translations
692 foreach($Translation as $symbol=>$trans){
693 $templateCode = str_replace("<%%TRANSLATION($symbol)%%>", $trans, $templateCode);
694 }
695
696 // clear scrap
697 $templateCode = str_replace('<%%', '<!-- ', $templateCode);
698 $templateCode = str_replace('%%>', ' -->', $templateCode);
699
700 // hide links to inaccessible tables
701 if($_REQUEST['dvprint_x'] == ''){
702 $templateCode .= "\n\n<script>\$j(function(){\n";
703 $arrTables = getTableList();
704 foreach($arrTables as $name => $caption){
705 $templateCode .= "\t\$j('#{$name}_link').removeClass('hidden');\n";
706 $templateCode .= "\t\$j('#xs_{$name}_link').removeClass('hidden');\n";
707 }
708
709 $templateCode .= $jsReadOnly;
710 $templateCode .= $jsEditable;
711
712 if(!$selected_id){
713 }
714
715 $templateCode.="\n});</script>\n";
716 }
717
718 // ajaxed auto-fill fields
719 $templateCode .= '<script>';
720 $templateCode .= '$j(function() {';
721
722
723 $templateCode.="});";
724 $templateCode.="</script>";
725 $templateCode .= $lookups;
726
727 // handle enforced parent values for read-only lookup fields
728
729 // don't include blank images in lightbox gallery
730 $templateCode = preg_replace('/blank.gif" data-lightbox=".*?"/', 'blank.gif"', $templateCode);
731
732 // don't display empty email links
733 $templateCode=preg_replace('/<a .*?href="mailto:".*?<\/a>/', '', $templateCode);
734
735 /* default field values */
736 $rdata = $jdata = get_defaults('class_time_table');
737 if($selected_id){
738 $jdata = get_joined_record('class_time_table', $selected_id);
739 if($jdata === false) $jdata = get_defaults('class_time_table');
740 $rdata = $row;
741 }
742 $templateCode .= loadView('class_time_table-ajax-cache', array('rdata' => $rdata, 'jdata' => $jdata));
743
744 // hook: class_time_table_dv
745 if(function_exists('class_time_table_dv')){
746 $args=array();
747 class_time_table_dv(($selected_id ? $selected_id : FALSE), getMemberInfo(), $templateCode, $args);
748 }
749
750 return $templateCode;
751 }
752 ?>
2
3 // Data functions (insert, update, delete, form) for table class_time_table
4
5 // This script and data application were generated by AppGini 5.72
6 // Download AppGini for free from https://bigprof.com/appgini/download/
7
8 function class_time_table_insert(){
9 global $Translation;
10
11 // mm: can member insert record?
12 $arrPerm=getTablePermissions('class_time_table');
13 if(!$arrPerm[1]){
14 return false;
15 }
16
17 $data['day'] = makeSafe($_REQUEST['day']);
18 if($data['day'] == empty_lookup_value){ $data['day'] = ''; }
19 $data['time_start'] = makeSafe($_REQUEST['time_start']);
20 if($data['time_start'] == empty_lookup_value){ $data['time_start'] = ''; }
21 $data['time_start'] = time24($data['time_start']);
22 $data['time_end'] = makeSafe($_REQUEST['time_end']);
23 if($data['time_end'] == empty_lookup_value){ $data['time_end'] = ''; }
24 $data['time_end'] = time24($data['time_end']);
25 $data['unit_code'] = makeSafe($_REQUEST['unit_code']);
26 if($data['unit_code'] == empty_lookup_value){ $data['unit_code'] = ''; }
27 $data['venue'] = makeSafe($_REQUEST['venue']);
28 if($data['venue'] == empty_lookup_value){ $data['venue'] = ''; }
29 $data['school'] = makeSafe($_REQUEST['school']);
30 if($data['school'] == empty_lookup_value){ $data['school'] = ''; }
31 $data['department'] = makeSafe($_REQUEST['department']);
32 if($data['department'] == empty_lookup_value){ $data['department'] = ''; }
33 $data['year_of_study'] = makeSafe($_REQUEST['year_of_study']);
34 if($data['year_of_study'] == empty_lookup_value){ $data['year_of_study'] = ''; }
35 if($data['day']== ''){
36 echo StyleSheet() . "\n\n<div class=\"alert alert-danger\">" . $Translation['error:'] . " 'Day': " . $Translation['field not null'] . '<br><br>';
37 echo '<a href="" onclick="history.go(-1); return false;">'.$Translation['< back'].'</a></div>';
38 exit;
39 }
40 if($data['time_start']== ''){
41 echo StyleSheet() . "\n\n<div class=\"alert alert-danger\">" . $Translation['error:'] . " ' Time Start': " . $Translation['field not null'] . '<br><br>';
42 echo '<a href="" onclick="history.go(-1); return false;">'.$Translation['< back'].'</a></div>';
43 exit;
44 }
45 if($data['time_end']== ''){
46 echo StyleSheet() . "\n\n<div class=\"alert alert-danger\">" . $Translation['error:'] . " 'Time End': " . $Translation['field not null'] . '<br><br>';
47 echo '<a href="" onclick="history.go(-1); return false;">'.$Translation['< back'].'</a></div>';
48 exit;
49 }
50 if($data['unit_code']== ''){
51 echo StyleSheet() . "\n\n<div class=\"alert alert-danger\">" . $Translation['error:'] . " 'Unit code': " . $Translation['field not null'] . '<br><br>';
52 echo '<a href="" onclick="history.go(-1); return false;">'.$Translation['< back'].'</a></div>';
53 exit;
54 }
55 if($data['venue']== ''){
56 echo StyleSheet() . "\n\n<div class=\"alert alert-danger\">" . $Translation['error:'] . " 'Venue': " . $Translation['field not null'] . '<br><br>';
57 echo '<a href="" onclick="history.go(-1); return false;">'.$Translation['< back'].'</a></div>';
58 exit;
59 }
60 if($data['school']== ''){
61 echo StyleSheet() . "\n\n<div class=\"alert alert-danger\">" . $Translation['error:'] . " 'School': " . $Translation['field not null'] . '<br><br>';
62 echo '<a href="" onclick="history.go(-1); return false;">'.$Translation['< back'].'</a></div>';
63 exit;
64 }
65 if($data['department']== ''){
66 echo StyleSheet() . "\n\n<div class=\"alert alert-danger\">" . $Translation['error:'] . " 'Department': " . $Translation['field not null'] . '<br><br>';
67 echo '<a href="" onclick="history.go(-1); return false;">'.$Translation['< back'].'</a></div>';
68 exit;
69 }
70 if($data['year_of_study']== ''){
71 echo StyleSheet() . "\n\n<div class=\"alert alert-danger\">" . $Translation['error:'] . " 'Year of study': " . $Translation['field not null'] . '<br><br>';
72 echo '<a href="" onclick="history.go(-1); return false;">'.$Translation['< back'].'</a></div>';
73 exit;
74 }
75
76 // hook: class_time_table_before_insert
77 if(function_exists('class_time_table_before_insert')){
78 $args=array();
79 if(!class_time_table_before_insert($data, getMemberInfo(), $args)){ return false; }
80 }
81
82 $o = array('silentErrors' => true);
83 sql('insert into `class_time_table` set `day`=' . (($data['day'] !== '' && $data['day'] !== NULL) ? "'{$data['day']}'" : 'NULL') . ', `time_start`=' . (($data['time_start'] !== '' && $data['time_start'] !== NULL) ? "'{$data['time_start']}'" : 'NULL') . ', `time_end`=' . (($data['time_end'] !== '' && $data['time_end'] !== NULL) ? "'{$data['time_end']}'" : 'NULL') . ', `unit_code`=' . (($data['unit_code'] !== '' && $data['unit_code'] !== NULL) ? "'{$data['unit_code']}'" : 'NULL') . ', `venue`=' . (($data['venue'] !== '' && $data['venue'] !== NULL) ? "'{$data['venue']}'" : 'NULL') . ', `school`=' . (($data['school'] !== '' && $data['school'] !== NULL) ? "'{$data['school']}'" : 'NULL') . ', `department`=' . (($data['department'] !== '' && $data['department'] !== NULL) ? "'{$data['department']}'" : 'NULL') . ', `year_of_study`=' . (($data['year_of_study'] !== '' && $data['year_of_study'] !== NULL) ? "'{$data['year_of_study']}'" : 'NULL'), $o);
84 if($o['error']!=''){
85 echo $o['error'];
86 echo "<a href=\"class_time_table_view.php?addNew_x=1\">{$Translation['< back']}</a>";
87 exit;
88 }
89
90 $recID = db_insert_id(db_link());
91
92 // hook: class_time_table_after_insert
93 if(function_exists('class_time_table_after_insert')){
94 $res = sql("select * from `class_time_table` where `id`='" . makeSafe($recID, false) . "' limit 1", $eo);
95 if($row = db_fetch_assoc($res)){
96 $data = array_map('makeSafe', $row);
97 }
98 $data['selectedID'] = makeSafe($recID, false);
99 $args=array();
100 if(!class_time_table_after_insert($data, getMemberInfo(), $args)){ return $recID; }
101 }
102
103 // mm: save ownership data
104 set_record_owner('class_time_table', $recID, getLoggedMemberID());
105
106 return $recID;
107 }
108
109 function class_time_table_delete($selected_id, $AllowDeleteOfParents=false, $skipChecks=false){
110 // insure referential integrity ...
111 global $Translation;
112 $selected_id=makeSafe($selected_id);
113
114 // mm: can member delete record?
115 $arrPerm=getTablePermissions('class_time_table');
116 $ownerGroupID=sqlValue("select groupID from membership_userrecords where tableName='class_time_table' and pkValue='$selected_id'");
117 $ownerMemberID=sqlValue("select lcase(memberID) from membership_userrecords where tableName='class_time_table' and pkValue='$selected_id'");
118 if(($arrPerm[4]==1 && $ownerMemberID==getLoggedMemberID()) || ($arrPerm[4]==2 && $ownerGroupID==getLoggedGroupID()) || $arrPerm[4]==3){ // allow delete?
119 // delete allowed, so continue ...
120 }else{
121 return $Translation['You don\'t have enough permissions to delete this record'];
122 }
123
124 // hook: class_time_table_before_delete
125 if(function_exists('class_time_table_before_delete')){
126 $args=array();
127 if(!class_time_table_before_delete($selected_id, $skipChecks, getMemberInfo(), $args))
128 return $Translation['Couldn\'t delete this record'];
129 }
130
131 sql("delete from `class_time_table` where `id`='$selected_id'", $eo);
132
133 // hook: class_time_table_after_delete
134 if(function_exists('class_time_table_after_delete')){
135 $args=array();
136 class_time_table_after_delete($selected_id, getMemberInfo(), $args);
137 }
138
139 // mm: delete ownership data
140 sql("delete from membership_userrecords where tableName='class_time_table' and pkValue='$selected_id'", $eo);
141 }
142
143 function class_time_table_update($selected_id){
144 global $Translation;
145
146 // mm: can member edit record?
147 $arrPerm=getTablePermissions('class_time_table');
148 $ownerGroupID=sqlValue("select groupID from membership_userrecords where tableName='class_time_table' and pkValue='".makeSafe($selected_id)."'");
149 $ownerMemberID=sqlValue("select lcase(memberID) from membership_userrecords where tableName='class_time_table' and pkValue='".makeSafe($selected_id)."'");
150 if(($arrPerm[3]==1 && $ownerMemberID==getLoggedMemberID()) || ($arrPerm[3]==2 && $ownerGroupID==getLoggedGroupID()) || $arrPerm[3]==3){ // allow update?
151 // update allowed, so continue ...
152 }else{
153 return false;
154 }
155
156 $data['day'] = makeSafe($_REQUEST['day']);
157 if($data['day'] == empty_lookup_value){ $data['day'] = ''; }
158 if($data['day']==''){
159 echo StyleSheet() . "\n\n<div class=\"alert alert-danger\">{$Translation['error:']} 'Day': {$Translation['field not null']}<br><br>";
160 echo '<a href="" onclick="history.go(-1); return false;">'.$Translation['< back'].'</a></div>';
161 exit;
162 }
163 $data['time_start'] = makeSafe($_REQUEST['time_start']);
164 if($data['time_start'] == empty_lookup_value){ $data['time_start'] = ''; }
165 $data['time_start'] = time24($data['time_start']);
166 if($data['time_start']==''){
167 echo StyleSheet() . "\n\n<div class=\"alert alert-danger\">{$Translation['error:']} ' Time Start': {$Translation['field not null']}<br><br>";
168 echo '<a href="" onclick="history.go(-1); return false;">'.$Translation['< back'].'</a></div>';
169 exit;
170 }
171 $data['time_end'] = makeSafe($_REQUEST['time_end']);
172 if($data['time_end'] == empty_lookup_value){ $data['time_end'] = ''; }
173 $data['time_end'] = time24($data['time_end']);
174 if($data['time_end']==''){
175 echo StyleSheet() . "\n\n<div class=\"alert alert-danger\">{$Translation['error:']} 'Time End': {$Translation['field not null']}<br><br>";
176 echo '<a href="" onclick="history.go(-1); return false;">'.$Translation['< back'].'</a></div>';
177 exit;
178 }
179 $data['unit_code'] = makeSafe($_REQUEST['unit_code']);
180 if($data['unit_code'] == empty_lookup_value){ $data['unit_code'] = ''; }
181 if($data['unit_code']==''){
182 echo StyleSheet() . "\n\n<div class=\"alert alert-danger\">{$Translation['error:']} 'Unit code': {$Translation['field not null']}<br><br>";
183 echo '<a href="" onclick="history.go(-1); return false;">'.$Translation['< back'].'</a></div>';
184 exit;
185 }
186 $data['venue'] = makeSafe($_REQUEST['venue']);
187 if($data['venue'] == empty_lookup_value){ $data['venue'] = ''; }
188 if($data['venue']==''){
189 echo StyleSheet() . "\n\n<div class=\"alert alert-danger\">{$Translation['error:']} 'Venue': {$Translation['field not null']}<br><br>";
190 echo '<a href="" onclick="history.go(-1); return false;">'.$Translation['< back'].'</a></div>';
191 exit;
192 }
193 $data['school'] = makeSafe($_REQUEST['school']);
194 if($data['school'] == empty_lookup_value){ $data['school'] = ''; }
195 if($data['school']==''){
196 echo StyleSheet() . "\n\n<div class=\"alert alert-danger\">{$Translation['error:']} 'School': {$Translation['field not null']}<br><br>";
197 echo '<a href="" onclick="history.go(-1); return false;">'.$Translation['< back'].'</a></div>';
198 exit;
199 }
200 $data['department'] = makeSafe($_REQUEST['department']);
201 if($data['department'] == empty_lookup_value){ $data['department'] = ''; }
202 if($data['department']==''){
203 echo StyleSheet() . "\n\n<div class=\"alert alert-danger\">{$Translation['error:']} 'Department': {$Translation['field not null']}<br><br>";
204 echo '<a href="" onclick="history.go(-1); return false;">'.$Translation['< back'].'</a></div>';
205 exit;
206 }
207 $data['year_of_study'] = makeSafe($_REQUEST['year_of_study']);
208 if($data['year_of_study'] == empty_lookup_value){ $data['year_of_study'] = ''; }
209 if($data['year_of_study']==''){
210 echo StyleSheet() . "\n\n<div class=\"alert alert-danger\">{$Translation['error:']} 'Year of study': {$Translation['field not null']}<br><br>";
211 echo '<a href="" onclick="history.go(-1); return false;">'.$Translation['< back'].'</a></div>';
212 exit;
213 }
214 $data['selectedID']=makeSafe($selected_id);
215
216 // hook: class_time_table_before_update
217 if(function_exists('class_time_table_before_update')){
218 $args=array();
219 if(!class_time_table_before_update($data, getMemberInfo(), $args)){ return false; }
220 }
221
222 $o=array('silentErrors' => true);
223 sql('update `class_time_table` set `day`=' . (($data['day'] !== '' && $data['day'] !== NULL) ? "'{$data['day']}'" : 'NULL') . ', `time_start`=' . (($data['time_start'] !== '' && $data['time_start'] !== NULL) ? "'{$data['time_start']}'" : 'NULL') . ', `time_end`=' . (($data['time_end'] !== '' && $data['time_end'] !== NULL) ? "'{$data['time_end']}'" : 'NULL') . ', `unit_code`=' . (($data['unit_code'] !== '' && $data['unit_code'] !== NULL) ? "'{$data['unit_code']}'" : 'NULL') . ', `venue`=' . (($data['venue'] !== '' && $data['venue'] !== NULL) ? "'{$data['venue']}'" : 'NULL') . ', `school`=' . (($data['school'] !== '' && $data['school'] !== NULL) ? "'{$data['school']}'" : 'NULL') . ', `department`=' . (($data['department'] !== '' && $data['department'] !== NULL) ? "'{$data['department']}'" : 'NULL') . ', `year_of_study`=' . (($data['year_of_study'] !== '' && $data['year_of_study'] !== NULL) ? "'{$data['year_of_study']}'" : 'NULL') . " where `id`='".makeSafe($selected_id)."'", $o);
224 if($o['error']!=''){
225 echo $o['error'];
226 echo '<a href="class_time_table_view.php?SelectedID='.urlencode($selected_id)."\">{$Translation['< back']}</a>";
227 exit;
228 }
229
230
231 // hook: class_time_table_after_update
232 if(function_exists('class_time_table_after_update')){
233 $res = sql("SELECT * FROM `class_time_table` WHERE `id`='{$data['selectedID']}' LIMIT 1", $eo);
234 if($row = db_fetch_assoc($res)){
235 $data = array_map('makeSafe', $row);
236 }
237 $data['selectedID'] = $data['id'];
238 $args = array();
239 if(!class_time_table_after_update($data, getMemberInfo(), $args)){ return; }
240 }
241
242 // mm: update ownership data
243 sql("update membership_userrecords set dateUpdated='".time()."' where tableName='class_time_table' and pkValue='".makeSafe($selected_id)."'", $eo);
244
245 }
246
247 function class_time_table_form($selected_id = '', $AllowUpdate = 1, $AllowInsert = 1, $AllowDelete = 1, $ShowCancel = 0, $TemplateDV = '', $TemplateDVP = ''){
248 // function to return an editable form for a table records
249 // and fill it with data of record whose ID is $selected_id. If $selected_id
250 // is empty, an empty form is shown, with only an 'Add New'
251 // button displayed.
252
253 global $Translation;
254
255 // mm: get table permissions
256 $arrPerm=getTablePermissions('class_time_table');
257 if(!$arrPerm[1] && $selected_id==''){ return ''; }
258 $AllowInsert = ($arrPerm[1] ? true : false);
259 // print preview?
260 $dvprint = false;
261 if($selected_id && $_REQUEST['dvprint_x'] != ''){
262 $dvprint = true;
263 }
264
265 $filterer_school = thisOr(undo_magic_quotes($_REQUEST['filterer_school']), '');
266 $filterer_department = thisOr(undo_magic_quotes($_REQUEST['filterer_department']), '');
267
268 // populate filterers, starting from children to grand-parents
269 if($filterer_department && !$filterer_school) $filterer_school = sqlValue("select school from departments where id='" . makeSafe($filterer_department) . "'");
270
271 // unique random identifier
272 $rnd1 = ($dvprint ? rand(1000000, 9999999) : '');
273 // combobox: day
274 $combo_day = new Combo;
275 $combo_day->ListType = 0;
276 $combo_day->MultipleSeparator = ', ';
277 $combo_day->ListBoxHeight = 10;
278 $combo_day->RadiosPerLine = 1;
279 if(is_file(dirname(__FILE__).'/hooks/class_time_table.day.csv')){
280 $day_data = addslashes(implode('', @file(dirname(__FILE__).'/hooks/class_time_table.day.csv')));
281 $combo_day->ListItem = explode('||', entitiesToUTF8(convertLegacyOptions($day_data)));
282 $combo_day->ListData = $combo_day->ListItem;
283 }else{
284 $combo_day->ListItem = explode('||', entitiesToUTF8(convertLegacyOptions("Monday;;Tuesday;;Wednesday;;Thursday;;Friday;;Saturday;;Sunday")));
285 $combo_day->ListData = $combo_day->ListItem;
286 }
287 $combo_day->SelectName = 'day';
288 $combo_day->AllowNull = false;
289 // combobox: school
290 $combo_school = new DataCombo;
291 // combobox: department, filterable by: school
292 $combo_department = new DataCombo;
293 // combobox: year_of_study
294 $combo_year_of_study = new Combo;
295 $combo_year_of_study->ListType = 0;
296 $combo_year_of_study->MultipleSeparator = ', ';
297 $combo_year_of_study->ListBoxHeight = 10;
298 $combo_year_of_study->RadiosPerLine = 1;
299 if(is_file(dirname(__FILE__).'/hooks/class_time_table.year_of_study.csv')){
300 $year_of_study_data = addslashes(implode('', @file(dirname(__FILE__).'/hooks/class_time_table.year_of_study.csv')));
301 $combo_year_of_study->ListItem = explode('||', entitiesToUTF8(convertLegacyOptions($year_of_study_data)));
302 $combo_year_of_study->ListData = $combo_year_of_study->ListItem;
303 }else{
304 $combo_year_of_study->ListItem = explode('||', entitiesToUTF8(convertLegacyOptions("1;;2;;3;;4;;5;;6")));
305 $combo_year_of_study->ListData = $combo_year_of_study->ListItem;
306 }
307 $combo_year_of_study->SelectName = 'year_of_study';
308 $combo_year_of_study->AllowNull = false;
309
310 if($selected_id){
311 // mm: check member permissions
312 if(!$arrPerm[2]){
313 return "";
314 }
315 // mm: who is the owner?
316 $ownerGroupID=sqlValue("select groupID from membership_userrecords where tableName='class_time_table' and pkValue='".makeSafe($selected_id)."'");
317 $ownerMemberID=sqlValue("select lcase(memberID) from membership_userrecords where tableName='class_time_table' and pkValue='".makeSafe($selected_id)."'");
318 if($arrPerm[2]==1 && getLoggedMemberID()!=$ownerMemberID){
319 return "";
320 }
321 if($arrPerm[2]==2 && getLoggedGroupID()!=$ownerGroupID){
322 return "";
323 }
324
325 // can edit?
326 if(($arrPerm[3]==1 && $ownerMemberID==getLoggedMemberID()) || ($arrPerm[3]==2 && $ownerGroupID==getLoggedGroupID()) || $arrPerm[3]==3){
327 $AllowUpdate=1;
328 }else{
329 $AllowUpdate=0;
330 }
331
332 $res = sql("select * from `class_time_table` where `id`='".makeSafe($selected_id)."'", $eo);
333 if(!($row = db_fetch_array($res))){
334 return error_message($Translation['No records found'], 'class_time_table_view.php', false);
335 }
336 $urow = $row; /* unsanitized data */
337 $hc = new CI_Input();
338 $row = $hc->xss_clean($row); /* sanitize data */
339 $combo_day->SelectedData = $row['day'];
340 $combo_school->SelectedData = $row['school'];
341 $combo_department->SelectedData = $row['department'];
342 $combo_year_of_study->SelectedData = $row['year_of_study'];
343 }else{
344 $combo_day->SelectedText = ( $_REQUEST['FilterField'][1]=='2' && $_REQUEST['FilterOperator'][1]=='<=>' ? (get_magic_quotes_gpc() ? stripslashes($_REQUEST['FilterValue'][1]) : $_REQUEST['FilterValue'][1]) : "");
345 $combo_school->SelectedData = $filterer_school;
346 $combo_department->SelectedData = $filterer_department;
347 $combo_year_of_study->SelectedText = ( $_REQUEST['FilterField'][1]=='9' && $_REQUEST['FilterOperator'][1]=='<=>' ? (get_magic_quotes_gpc() ? stripslashes($_REQUEST['FilterValue'][1]) : $_REQUEST['FilterValue'][1]) : "");
348 }
349 $combo_day->Render();
350 $combo_school->HTML = '<span id="school-container' . $rnd1 . '"></span><input type="hidden" name="school" id="school' . $rnd1 . '" value="' . html_attr($combo_school->SelectedData) . '">';
351 $combo_school->MatchText = '<span id="school-container-readonly' . $rnd1 . '"></span><input type="hidden" name="school" id="school' . $rnd1 . '" value="' . html_attr($combo_school->SelectedData) . '">';
352 $combo_department->HTML = '<span id="department-container' . $rnd1 . '"></span><input type="hidden" name="department" id="department' . $rnd1 . '" value="' . html_attr($combo_department->SelectedData) . '">';
353 $combo_department->MatchText = '<span id="department-container-readonly' . $rnd1 . '"></span><input type="hidden" name="department" id="department' . $rnd1 . '" value="' . html_attr($combo_department->SelectedData) . '">';
354 $combo_year_of_study->Render();
355
356 ob_start();
357 ?>
358
359 <script>
360 // initial lookup values
361 AppGini.current_school__RAND__ = { text: "", value: "<?php echo addslashes($selected_id ? $urow['school'] : $filterer_school); ?>"};
362 AppGini.current_department__RAND__ = { text: "", value: "<?php echo addslashes($selected_id ? $urow['department'] : $filterer_department); ?>"};
363
364 jQuery(function() {
365 setTimeout(function(){
366 if(typeof(school_reload__RAND__) == 'function') school_reload__RAND__();
367 <?php echo (!$AllowUpdate || $dvprint ? 'if(typeof(department_reload__RAND__) == \'function\') department_reload__RAND__(AppGini.current_school__RAND__.value);' : ''); ?>
368 }, 10); /* we need to slightly delay client-side execution of the above code to allow AppGini.ajaxCache to work */
369 });
370 function school_reload__RAND__(){
371 <?php if(($AllowUpdate || $AllowInsert) && !$dvprint){ ?>
372
373 $j("#school-container__RAND__").select2({
374 /* initial default value */
375 initSelection: function(e, c){
376 $j.ajax({
377 url: 'ajax_combo.php',
378 dataType: 'json',
379 data: { id: AppGini.current_school__RAND__.value, t: 'class_time_table', f: 'school' },
380 success: function(resp){
381 c({
382 id: resp.results[0].id,
383 text: resp.results[0].text
384 });
385 $j('[name="school"]').val(resp.results[0].id);
386 $j('[id=school-container-readonly__RAND__]').html('<span id="school-match-text">' + resp.results[0].text + '</span>');
387 if(resp.results[0].id == '<?php echo empty_lookup_value; ?>'){ $j('.btn[id=schools_view_parent]').hide(); }else{ $j('.btn[id=schools_view_parent]').show(); }
388
389 if(typeof(department_reload__RAND__) == 'function') department_reload__RAND__(AppGini.current_school__RAND__.value);
390
391 if(typeof(school_update_autofills__RAND__) == 'function') school_update_autofills__RAND__();
392 }
393 });
394 },
395 width: '100%',
396 formatNoMatches: function(term){ /* */ return '<?php echo addslashes($Translation['No matches found!']); ?>'; },
397 minimumResultsForSearch: 10,
398 loadMorePadding: 200,
399 ajax: {
400 url: 'ajax_combo.php',
401 dataType: 'json',
402 cache: true,
403 data: function(term, page){ /* */ return { s: term, p: page, t: 'class_time_table', f: 'school' }; },
404 results: function(resp, page){ /* */ return resp; }
405 },
406 escapeMarkup: function(str){ /* */ return str; }
407 }).on('change', function(e){
408 AppGini.current_school__RAND__.value = e.added.id;
409 AppGini.current_school__RAND__.text = e.added.text;
410 $j('[name="school"]').val(e.added.id);
411 if(e.added.id == '<?php echo empty_lookup_value; ?>'){ $j('.btn[id=schools_view_parent]').hide(); }else{ $j('.btn[id=schools_view_parent]').show(); }
412
413 if(typeof(department_reload__RAND__) == 'function') department_reload__RAND__(AppGini.current_school__RAND__.value);
414
415 if(typeof(school_update_autofills__RAND__) == 'function') school_update_autofills__RAND__();
416 });
417
418 if(!$j("#school-container__RAND__").length){
419 $j.ajax({
420 url: 'ajax_combo.php',
421 dataType: 'json',
422 data: { id: AppGini.current_school__RAND__.value, t: 'class_time_table', f: 'school' },
423 success: function(resp){
424 $j('[name="school"]').val(resp.results[0].id);
425 $j('[id=school-container-readonly__RAND__]').html('<span id="school-match-text">' + resp.results[0].text + '</span>');
426 if(resp.results[0].id == '<?php echo empty_lookup_value; ?>'){ $j('.btn[id=schools_view_parent]').hide(); }else{ $j('.btn[id=schools_view_parent]').show(); }
427
428 if(typeof(school_update_autofills__RAND__) == 'function') school_update_autofills__RAND__();
429 }
430 });
431 }
432
433 <?php }else{ ?>
434
435 $j.ajax({
436 url: 'ajax_combo.php',
437 dataType: 'json',
438 data: { id: AppGini.current_school__RAND__.value, t: 'class_time_table', f: 'school' },
439 success: function(resp){
440 $j('[id=school-container__RAND__], [id=school-container-readonly__RAND__]').html('<span id="school-match-text">' + resp.results[0].text + '</span>');
441 if(resp.results[0].id == '<?php echo empty_lookup_value; ?>'){ $j('.btn[id=schools_view_parent]').hide(); }else{ $j('.btn[id=schools_view_parent]').show(); }
442
443 if(typeof(school_update_autofills__RAND__) == 'function') school_update_autofills__RAND__();
444 }
445 });
446 <?php } ?>
447
448 }
449 function department_reload__RAND__(filterer_school){
450 <?php if(($AllowUpdate || $AllowInsert) && !$dvprint){ ?>
451
452 $j("#department-container__RAND__").select2({
453 /* initial default value */
454 initSelection: function(e, c){
455 $j.ajax({
456 url: 'ajax_combo.php',
457 dataType: 'json',
458 data: { filterer_school: filterer_school, id: AppGini.current_department__RAND__.value, t: 'class_time_table', f: 'department' },
459 success: function(resp){
460 c({
461 id: resp.results[0].id,
462 text: resp.results[0].text
463 });
464 $j('[name="department"]').val(resp.results[0].id);
465 $j('[id=department-container-readonly__RAND__]').html('<span id="department-match-text">' + resp.results[0].text + '</span>');
466 if(resp.results[0].id == '<?php echo empty_lookup_value; ?>'){ $j('.btn[id=departments_view_parent]').hide(); }else{ $j('.btn[id=departments_view_parent]').show(); }
467
468
469 if(typeof(department_update_autofills__RAND__) == 'function') department_update_autofills__RAND__();
470 }
471 });
472 },
473 width: '100%',
474 formatNoMatches: function(term){ /* */ return '<?php echo addslashes($Translation['No matches found!']); ?>'; },
475 minimumResultsForSearch: 10,
476 loadMorePadding: 200,
477 ajax: {
478 url: 'ajax_combo.php',
479 dataType: 'json',
480 cache: true,
481 data: function(term, page){ /* */ return { filterer_school: filterer_school, s: term, p: page, t: 'class_time_table', f: 'department' }; },
482 results: function(resp, page){ /* */ return resp; }
483 },
484 escapeMarkup: function(str){ /* */ return str; }
485 }).on('change', function(e){
486 AppGini.current_department__RAND__.value = e.added.id;
487 AppGini.current_department__RAND__.text = e.added.text;
488 $j('[name="department"]').val(e.added.id);
489 if(e.added.id == '<?php echo empty_lookup_value; ?>'){ $j('.btn[id=departments_view_parent]').hide(); }else{ $j('.btn[id=departments_view_parent]').show(); }
490
491
492 if(typeof(department_update_autofills__RAND__) == 'function') department_update_autofills__RAND__();
493 });
494
495 if(!$j("#department-container__RAND__").length){
496 $j.ajax({
497 url: 'ajax_combo.php',
498 dataType: 'json',
499 data: { id: AppGini.current_department__RAND__.value, t: 'class_time_table', f: 'department' },
500 success: function(resp){
501 $j('[name="department"]').val(resp.results[0].id);
502 $j('[id=department-container-readonly__RAND__]').html('<span id="department-match-text">' + resp.results[0].text + '</span>');
503 if(resp.results[0].id == '<?php echo empty_lookup_value; ?>'){ $j('.btn[id=departments_view_parent]').hide(); }else{ $j('.btn[id=departments_view_parent]').show(); }
504
505 if(typeof(department_update_autofills__RAND__) == 'function') department_update_autofills__RAND__();
506 }
507 });
508 }
509
510 <?php }else{ ?>
511
512 $j.ajax({
513 url: 'ajax_combo.php',
514 dataType: 'json',
515 data: { id: AppGini.current_department__RAND__.value, t: 'class_time_table', f: 'department' },
516 success: function(resp){
517 $j('[id=department-container__RAND__], [id=department-container-readonly__RAND__]').html('<span id="department-match-text">' + resp.results[0].text + '</span>');
518 if(resp.results[0].id == '<?php echo empty_lookup_value; ?>'){ $j('.btn[id=departments_view_parent]').hide(); }else{ $j('.btn[id=departments_view_parent]').show(); }
519
520 if(typeof(department_update_autofills__RAND__) == 'function') department_update_autofills__RAND__();
521 }
522 });
523 <?php } ?>
524
525 }
526 </script>
527 <?php
528
529 $lookups = str_replace('__RAND__', $rnd1, ob_get_contents());
530 ob_end_clean();
531
532
533 // code for template based detail view forms
534
535 // open the detail view template
536 if($dvprint){
537 $template_file = is_file("./{$TemplateDVP}") ? "./{$TemplateDVP}" : './templates/class_time_table_templateDVP.html';
538 $templateCode = @file_get_contents($template_file);
539 }else{
540 $template_file = is_file("./{$TemplateDV}") ? "./{$TemplateDV}" : './templates/class_time_table_templateDV.html';
541 $templateCode = @file_get_contents($template_file);
542 }
543
544 // process form title
545 $templateCode = str_replace('<%%DETAIL_VIEW_TITLE%%>', 'Thông tin lịch học', $templateCode);
546 $templateCode = str_replace('<%%RND1%%>', $rnd1, $templateCode);
547 $templateCode = str_replace('<%%EMBEDDED%%>', ($_REQUEST['Embedded'] ? 'Embedded=1' : ''), $templateCode);
548 // process buttons
549 if($AllowInsert){
550 if(!$selected_id) $templateCode = str_replace('<%%INSERT_BUTTON%%>', '<button type="submit" class="btn btn-success" id="insert" name="insert_x" value="1" onclick="return class_time_table_validateData();"><i class="glyphicon glyphicon-plus-sign"></i> ' . $Translation['Save New'] . '</button>', $templateCode);
551 $templateCode = str_replace('<%%INSERT_BUTTON%%>', '<button type="submit" class="btn btn-default" id="insert" name="insert_x" value="1" onclick="return class_time_table_validateData();"><i class="glyphicon glyphicon-plus-sign"></i> ' . $Translation['Save As Copy'] . '</button>', $templateCode);
552 }else{
553 $templateCode = str_replace('<%%INSERT_BUTTON%%>', '', $templateCode);
554 }
555
556 // 'Back' button action
557 if($_REQUEST['Embedded']){
558 $backAction = 'AppGini.closeParentModal(); return false;';
559 }else{
560 $backAction = '$j(\'form\').eq(0).attr(\'novalidate\', \'novalidate\'); document.myform.reset(); return true;';
561 }
562
563 if($selected_id){
564 if(!$_REQUEST['Embedded']) $templateCode = str_replace('<%%DVPRINT_BUTTON%%>', '<button type="submit" class="btn btn-default" id="dvprint" name="dvprint_x" value="1" onclick="$$(\'form\')[0].writeAttribute(\'novalidate\', \'novalidate\'); document.myform.reset(); return true;" title="' . html_attr($Translation['Print Preview']) . '"><i class="glyphicon glyphicon-print"></i> ' . $Translation['Print Preview'] . '</button>', $templateCode);
565 if($AllowUpdate){
566 $templateCode = str_replace('<%%UPDATE_BUTTON%%>', '<button type="submit" class="btn btn-success btn-lg" id="update" name="update_x" value="1" onclick="return class_time_table_validateData();" title="' . html_attr($Translation['Save Changes']) . '"><i class="glyphicon glyphicon-ok"></i> ' . $Translation['Save Changes'] . '</button>', $templateCode);
567 }else{
568 $templateCode = str_replace('<%%UPDATE_BUTTON%%>', '', $templateCode);
569 }
570 if(($arrPerm[4]==1 && $ownerMemberID==getLoggedMemberID()) || ($arrPerm[4]==2 && $ownerGroupID==getLoggedGroupID()) || $arrPerm[4]==3){ // allow delete?
571 $templateCode = str_replace('<%%DELETE_BUTTON%%>', '<button type="submit" class="btn btn-danger" id="delete" name="delete_x" value="1" onclick="return confirm(\'' . $Translation['are you sure?'] . '\');" title="' . html_attr($Translation['Delete']) . '"><i class="glyphicon glyphicon-trash"></i> ' . $Translation['Delete'] . '</button>', $templateCode);
572 }else{
573 $templateCode = str_replace('<%%DELETE_BUTTON%%>', '', $templateCode);
574 }
575 $templateCode = str_replace('<%%DESELECT_BUTTON%%>', '<button type="submit" class="btn btn-default" id="deselect" name="deselect_x" value="1" onclick="' . $backAction . '" title="' . html_attr($Translation['Back']) . '"><i class="glyphicon glyphicon-chevron-left"></i> ' . $Translation['Back'] . '</button>', $templateCode);
576 }else{
577 $templateCode = str_replace('<%%UPDATE_BUTTON%%>', '', $templateCode);
578 $templateCode = str_replace('<%%DELETE_BUTTON%%>', '', $templateCode);
579 $templateCode = str_replace('<%%DESELECT_BUTTON%%>', ($ShowCancel ? '<button type="submit" class="btn btn-default" id="deselect" name="deselect_x" value="1" onclick="' . $backAction . '" title="' . html_attr($Translation['Back']) . '"><i class="glyphicon glyphicon-chevron-left"></i> ' . $Translation['Back'] . '</button>' : ''), $templateCode);
580 }
581
582 // set records to read only if user can't insert new records and can't edit current record
583 if(($selected_id && !$AllowUpdate && !$AllowInsert) || (!$selected_id && !$AllowInsert)){
584 $jsReadOnly .= "\tjQuery('#day').replaceWith('<div class=\"form-control-static\" id=\"day\">' + (jQuery('#day').val() || '') + '</div>'); jQuery('#day-multi-selection-help').hide();\n";
585 $jsReadOnly .= "\tjQuery('#time_start').replaceWith('<div class=\"form-control-static\" id=\"time_start\">' + (jQuery('#time_start').val() || '') + '</div>');\n";
586 $jsReadOnly .= "\tjQuery('#time_end').replaceWith('<div class=\"form-control-static\" id=\"time_end\">' + (jQuery('#time_end').val() || '') + '</div>');\n";
587 $jsReadOnly .= "\tjQuery('#unit_code').replaceWith('<div class=\"form-control-static\" id=\"unit_code\">' + (jQuery('#unit_code').val() || '') + '</div>');\n";
588 $jsReadOnly .= "\tjQuery('#venue').replaceWith('<div class=\"form-control-static\" id=\"venue\">' + (jQuery('#venue').val() || '') + '</div>');\n";
589 $jsReadOnly .= "\tjQuery('#school').prop('disabled', true).css({ color: '#555', backgroundColor: '#fff' });\n";
590 $jsReadOnly .= "\tjQuery('#school_caption').prop('disabled', true).css({ color: '#555', backgroundColor: 'white' });\n";
591 $jsReadOnly .= "\tjQuery('#department').prop('disabled', true).css({ color: '#555', backgroundColor: '#fff' });\n";
592 $jsReadOnly .= "\tjQuery('#department_caption').prop('disabled', true).css({ color: '#555', backgroundColor: 'white' });\n";
593 $jsReadOnly .= "\tjQuery('#year_of_study').replaceWith('<div class=\"form-control-static\" id=\"year_of_study\">' + (jQuery('#year_of_study').val() || '') + '</div>'); jQuery('#year_of_study-multi-selection-help').hide();\n";
594 $jsReadOnly .= "\tjQuery('.select2-container').hide();\n";
595
596 $noUploads = true;
597 }elseif($AllowInsert){
598 $jsEditable .= "\tjQuery('form').eq(0).data('already_changed', true);"; // temporarily disable form change handler
599 $jsEditable .= "\tjQuery('#time_start').addClass('always_shown').timepicker({ defaultTime: false, showSeconds: true, showMeridian: true, showInputs: false, disableFocus: true, minuteStep: 5 });";
600 $jsEditable .= "\tjQuery('#time_end').addClass('always_shown').timepicker({ defaultTime: false, showSeconds: true, showMeridian: true, showInputs: false, disableFocus: true, minuteStep: 5 });";
601 $jsEditable .= "\tjQuery('form').eq(0).data('already_changed', false);"; // re-enable form change handler
602 }
603
604 // process combos
605 $templateCode = str_replace('<%%COMBO(day)%%>', $combo_day->HTML, $templateCode);
606 $templateCode = str_replace('<%%COMBOTEXT(day)%%>', $combo_day->SelectedData, $templateCode);
607 $templateCode = str_replace('<%%COMBO(school)%%>', $combo_school->HTML, $templateCode);
608 $templateCode = str_replace('<%%COMBOTEXT(school)%%>', $combo_school->MatchText, $templateCode);
609 $templateCode = str_replace('<%%URLCOMBOTEXT(school)%%>', urlencode($combo_school->MatchText), $templateCode);
610 $templateCode = str_replace('<%%COMBO(department)%%>', $combo_department->HTML, $templateCode);
611 $templateCode = str_replace('<%%COMBOTEXT(department)%%>', $combo_department->MatchText, $templateCode);
612 $templateCode = str_replace('<%%URLCOMBOTEXT(department)%%>', urlencode($combo_department->MatchText), $templateCode);
613 $templateCode = str_replace('<%%COMBO(year_of_study)%%>', $combo_year_of_study->HTML, $templateCode);
614 $templateCode = str_replace('<%%COMBOTEXT(year_of_study)%%>', $combo_year_of_study->SelectedData, $templateCode);
615
616 /* lookup fields array: 'lookup field name' => array('parent table name', 'lookup field caption') */
617 $lookup_fields = array( 'school' => array('schools', 'School'), 'department' => array('departments', 'Department'));
618 foreach($lookup_fields as $luf => $ptfc){
619 $pt_perm = getTablePermissions($ptfc[0]);
620
621 // process foreign key links
622 if($pt_perm['view'] || $pt_perm['edit']){
623 $templateCode = str_replace("<%%PLINK({$luf})%%>", '<button type="button" class="btn btn-default view_parent hspacer-md" id="' . $ptfc[0] . '_view_parent" title="' . html_attr($Translation['View'] . ' ' . $ptfc[1]) . '"><i class="glyphicon glyphicon-eye-open"></i></button>', $templateCode);
624 }
625
626 // if user has insert permission to parent table of a lookup field, put an add new button
627 if($pt_perm['insert'] && !$_REQUEST['Embedded']){
628 $templateCode = str_replace("<%%ADDNEW({$ptfc[0]})%%>", '<button type="button" class="btn btn-success add_new_parent hspacer-md" id="' . $ptfc[0] . '_add_new" title="' . html_attr($Translation['Add New'] . ' ' . $ptfc[1]) . '"><i class="glyphicon glyphicon-plus-sign"></i></button>', $templateCode);
629 }
630 }
631
632 // process images
633 $templateCode = str_replace('<%%UPLOADFILE(id)%%>', '', $templateCode);
634 $templateCode = str_replace('<%%UPLOADFILE(day)%%>', '', $templateCode);
635 $templateCode = str_replace('<%%UPLOADFILE(time_start)%%>', '', $templateCode);
636 $templateCode = str_replace('<%%UPLOADFILE(time_end)%%>', '', $templateCode);
637 $templateCode = str_replace('<%%UPLOADFILE(unit_code)%%>', '', $templateCode);
638 $templateCode = str_replace('<%%UPLOADFILE(venue)%%>', '', $templateCode);
639 $templateCode = str_replace('<%%UPLOADFILE(school)%%>', '', $templateCode);
640 $templateCode = str_replace('<%%UPLOADFILE(department)%%>', '', $templateCode);
641 $templateCode = str_replace('<%%UPLOADFILE(year_of_study)%%>', '', $templateCode);
642
643 // process values
644 if($selected_id){
645 if( $dvprint) $templateCode = str_replace('<%%VALUE(id)%%>', safe_html($urow['id']), $templateCode);
646 if(!$dvprint) $templateCode = str_replace('<%%VALUE(id)%%>', html_attr($row['id']), $templateCode);
647 $templateCode = str_replace('<%%URLVALUE(id)%%>', urlencode($urow['id']), $templateCode);
648 if( $dvprint) $templateCode = str_replace('<%%VALUE(day)%%>', safe_html($urow['day']), $templateCode);
649 if(!$dvprint) $templateCode = str_replace('<%%VALUE(day)%%>', html_attr($row['day']), $templateCode);
650 $templateCode = str_replace('<%%URLVALUE(day)%%>', urlencode($urow['day']), $templateCode);
651 $templateCode = str_replace('<%%VALUE(time_start)%%>', time12(html_attr($row['time_start'])), $templateCode);
652 $templateCode = str_replace('<%%URLVALUE(time_start)%%>', urlencode(time12($urow['time_start'])), $templateCode);
653 $templateCode = str_replace('<%%VALUE(time_end)%%>', time12(html_attr($row['time_end'])), $templateCode);
654 $templateCode = str_replace('<%%URLVALUE(time_end)%%>', urlencode(time12($urow['time_end'])), $templateCode);
655 if( $dvprint) $templateCode = str_replace('<%%VALUE(unit_code)%%>', safe_html($urow['unit_code']), $templateCode);
656 if(!$dvprint) $templateCode = str_replace('<%%VALUE(unit_code)%%>', html_attr($row['unit_code']), $templateCode);
657 $templateCode = str_replace('<%%URLVALUE(unit_code)%%>', urlencode($urow['unit_code']), $templateCode);
658 if( $dvprint) $templateCode = str_replace('<%%VALUE(venue)%%>', safe_html($urow['venue']), $templateCode);
659 if(!$dvprint) $templateCode = str_replace('<%%VALUE(venue)%%>', html_attr($row['venue']), $templateCode);
660 $templateCode = str_replace('<%%URLVALUE(venue)%%>', urlencode($urow['venue']), $templateCode);
661 if( $dvprint) $templateCode = str_replace('<%%VALUE(school)%%>', safe_html($urow['school']), $templateCode);
662 if(!$dvprint) $templateCode = str_replace('<%%VALUE(school)%%>', html_attr($row['school']), $templateCode);
663 $templateCode = str_replace('<%%URLVALUE(school)%%>', urlencode($urow['school']), $templateCode);
664 if( $dvprint) $templateCode = str_replace('<%%VALUE(department)%%>', safe_html($urow['department']), $templateCode);
665 if(!$dvprint) $templateCode = str_replace('<%%VALUE(department)%%>', html_attr($row['department']), $templateCode);
666 $templateCode = str_replace('<%%URLVALUE(department)%%>', urlencode($urow['department']), $templateCode);
667 if( $dvprint) $templateCode = str_replace('<%%VALUE(year_of_study)%%>', safe_html($urow['year_of_study']), $templateCode);
668 if(!$dvprint) $templateCode = str_replace('<%%VALUE(year_of_study)%%>', html_attr($row['year_of_study']), $templateCode);
669 $templateCode = str_replace('<%%URLVALUE(year_of_study)%%>', urlencode($urow['year_of_study']), $templateCode);
670 }else{
671 $templateCode = str_replace('<%%VALUE(id)%%>', '', $templateCode);
672 $templateCode = str_replace('<%%URLVALUE(id)%%>', urlencode(''), $templateCode);
673 $templateCode = str_replace('<%%VALUE(day)%%>', '', $templateCode);
674 $templateCode = str_replace('<%%URLVALUE(day)%%>', urlencode(''), $templateCode);
675 $templateCode = str_replace('<%%VALUE(time_start)%%>', time12(''), $templateCode);
676 $templateCode = str_replace('<%%URLVALUE(time_start)%%>', urlencode(time12('')), $templateCode);
677 $templateCode = str_replace('<%%VALUE(time_end)%%>', time12(''), $templateCode);
678 $templateCode = str_replace('<%%URLVALUE(time_end)%%>', urlencode(time12('')), $templateCode);
679 $templateCode = str_replace('<%%VALUE(unit_code)%%>', '', $templateCode);
680 $templateCode = str_replace('<%%URLVALUE(unit_code)%%>', urlencode(''), $templateCode);
681 $templateCode = str_replace('<%%VALUE(venue)%%>', '', $templateCode);
682 $templateCode = str_replace('<%%URLVALUE(venue)%%>', urlencode(''), $templateCode);
683 $templateCode = str_replace('<%%VALUE(school)%%>', '', $templateCode);
684 $templateCode = str_replace('<%%URLVALUE(school)%%>', urlencode(''), $templateCode);
685 $templateCode = str_replace('<%%VALUE(department)%%>', '', $templateCode);
686 $templateCode = str_replace('<%%URLVALUE(department)%%>', urlencode(''), $templateCode);
687 $templateCode = str_replace('<%%VALUE(year_of_study)%%>', '', $templateCode);
688 $templateCode = str_replace('<%%URLVALUE(year_of_study)%%>', urlencode(''), $templateCode);
689 }
690
691 // process translations
692 foreach($Translation as $symbol=>$trans){
693 $templateCode = str_replace("<%%TRANSLATION($symbol)%%>", $trans, $templateCode);
694 }
695
696 // clear scrap
697 $templateCode = str_replace('<%%', '<!-- ', $templateCode);
698 $templateCode = str_replace('%%>', ' -->', $templateCode);
699
700 // hide links to inaccessible tables
701 if($_REQUEST['dvprint_x'] == ''){
702 $templateCode .= "\n\n<script>\$j(function(){\n";
703 $arrTables = getTableList();
704 foreach($arrTables as $name => $caption){
705 $templateCode .= "\t\$j('#{$name}_link').removeClass('hidden');\n";
706 $templateCode .= "\t\$j('#xs_{$name}_link').removeClass('hidden');\n";
707 }
708
709 $templateCode .= $jsReadOnly;
710 $templateCode .= $jsEditable;
711
712 if(!$selected_id){
713 }
714
715 $templateCode.="\n});</script>\n";
716 }
717
718 // ajaxed auto-fill fields
719 $templateCode .= '<script>';
720 $templateCode .= '$j(function() {';
721
722
723 $templateCode.="});";
724 $templateCode.="</script>";
725 $templateCode .= $lookups;
726
727 // handle enforced parent values for read-only lookup fields
728
729 // don't include blank images in lightbox gallery
730 $templateCode = preg_replace('/blank.gif" data-lightbox=".*?"/', 'blank.gif"', $templateCode);
731
732 // don't display empty email links
733 $templateCode=preg_replace('/<a .*?href="mailto:".*?<\/a>/', '', $templateCode);
734
735 /* default field values */
736 $rdata = $jdata = get_defaults('class_time_table');
737 if($selected_id){
738 $jdata = get_joined_record('class_time_table', $selected_id);
739 if($jdata === false) $jdata = get_defaults('class_time_table');
740 $rdata = $row;
741 }
742 $templateCode .= loadView('class_time_table-ajax-cache', array('rdata' => $rdata, 'jdata' => $jdata));
743
744 // hook: class_time_table_dv
745 if(function_exists('class_time_table_dv')){
746 $args=array();
747 class_time_table_dv(($selected_id ? $selected_id : FALSE), getMemberInfo(), $templateCode, $args);
748 }
749
750 return $templateCode;
751 }
752 ?>